//
//  searchContactsFirView.m
//  HappyStore
//
//  Created by 陈锋 on 16/6/14.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "searchContactsFirView.h"

@implementation searchContactsFirView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        UIView * topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenW, 130)];
        topView.backgroundColor = [UIColor colorWithRed:67.0/255.0 green:177.0/255.0 blue:241.0/255.0 alpha:1];

        UIImageView * myFriendImg = [[UIImageView alloc]init];
        myFriendImg.frame = CGRectMake(55, 30,50, 70);
        myFriendImg.image = [UIImage imageNamed:@"WODE"];
        myFriendImg.contentMode = UIViewContentModeScaleAspectFit;
        [self addSubview:myFriendImg];

        UIImageView * addFriendImg = [[UIImageView alloc]init];
        addFriendImg.frame = CGRectMake(self.width/2 +55, 30,50, 70);
        addFriendImg.image = [UIImage imageNamed:@"我的人脉"];
        addFriendImg.contentMode = UIViewContentModeScaleAspectFit;
        [self addSubview:addFriendImg];


//        [self addSubview:topView];
        NSArray * labelText = @[@"找项目源",@"找投资人",@"找企业",@"同行",@"同城",@"老乡"];
        for (int i = 0; i < labelText.count; i++) {
            
            //创建按钮
            UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(i%3*screenW/3+20, i/3*90+140, 60, 70)];
            button.tag = i;
            [button setImage:[UIImage imageNamed:[NSString stringWithFormat:@"找人脉%d",i+1]] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:button];
            
        }
    }
    self.backgroundColor = [UIColor whiteColor];
    return self;
}

//按钮事件方法
-(void)clickButton:(UIButton *)button{
    NSLog(@"%ld",(long)button.tag);
    NSString * category = @"找项目源";
    switch (button.tag) {
        case 1:
            category = @"找投资人";
            break;
        case 2:
            category = @"找企业";
            break;
        case 3:
            category = @"同行";
            break;
        case 4:
            category = @"同城";
            break;
        case 5:
            category = @"找老乡";
            break;
            
        default:
            break;
    }
    
    //发送一条通知给MainTableViewController
    [[NSNotificationCenter defaultCenter]postNotificationName:@"clickCategory" object:nil userInfo:@{@"category":category}];
}

@end
